﻿using System;
using Newtonsoft.Json;
using System.Net.DnsToolkit.Packet;

namespace System.Net.DnsToolkit.Serializer.Json.Converter {

    public class QTypeEnumJsonConverter : JsonConverter {

        public override bool CanConvert(Type objectType) {
            return objectType == typeof(QTypeEnum);
        }

        public override object ReadJson(JsonReader reader, Type objectType, JsonSerializer serializer) {
            throw new NotImplementedException();
        }

        public override void WriteJson(JsonWriter w, object value, JsonSerializer serializer) {
            QTypeEnum qte = (QTypeEnum)value;
            w.WriteValue(string.Format("{0}", qte));
            w.WriteComment(string.Format(" {0} ", (ushort)qte));
        }
    }

}
